home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 18 / fpc103.zip / SEDCODE.SEQ < prev    next >
Text File  |  1988-06-30  |  4KB  |  112 lines

  1. \ SEDCODE.SEQ   The Assembly code needed for SED        by Tom Zimmer
  2.  
  3. only forth also hidden definitions also
  4.  
  5. code tb:        ( a1 -- tsegb a1 )      \ add text segment base to stack
  6.                 pop ax                  \ under a1 in prep for long operation
  7.                 mov dx, tsegb
  8.                 2push
  9.                 end-code
  10.  
  11. code tl:        ( a1 -- lseg a1 )       \ add list segment base to stack
  12.                 pop ax                  \ under a1 in prep for long operation
  13.                 mov dx, lseg
  14.                 2push
  15.                 end-code
  16.  
  17. code tl+        ( a1 --- a2 )   \ a2 = a1 + 2, the list entry size in bytes
  18.                 pop ax          add ax, # 2
  19.                 1push           end-code
  20.  
  21. code tl-        ( a1 --- a2 )   \ a2 = a1 - 2, the list entry size in bytes
  22.                 pop ax          sub ax, # 2
  23.                 1push           end-code
  24.  
  25. code tl*        ( n1 -- n2 )    \ n2 = n1 * 2, the list entry size in bytes
  26.                 pop ax          shl ax, # 1
  27.                 1push           end-code
  28.  
  29. code ?exit      ( f1 -- )  \ exit from definition on boolean f1.
  30.                 pop ax
  31.                 or ax, ax
  32.         0<> if
  33.                 jmp ' exit
  34.         then
  35.                 next
  36.                 end-code
  37.  
  38. code getdiskfree        \ return free space from disk
  39.                 ( dv --- avail.clusters bytes/sec secs/cluster )
  40.                 mov ah, # 54
  41.                 pop dx
  42.                 int 33
  43.                 push bx
  44.                 push cx
  45.                 1push
  46.                 end-code
  47.  
  48. code >lineptr   ( n1 --- a1 )
  49.                 pop ax
  50.                 shl ax, # 1
  51.                 1push
  52.                 end-code
  53.  
  54. code lineptr   ( --- a1 )
  55.                 mov ax, ' curline >body
  56.                 shl ax, # 1             \ shift left by 2, for word size
  57.                 1push                   \ of list pointer table.
  58.                 end-code
  59.  
  60. code tl:@       ( a1 -- n1 )
  61.                 pop bx          mov ds, lseg
  62.                 mov ax, 0 [bx]
  63.                 mov bx, cs      mov ds, bx
  64.                 1push           end-code
  65.  
  66. code tl:!       ( n adr -- )
  67.                 pop bx          mov ds, lseg
  68.                 pop ax          mov 0 [bx], ax
  69.                 mov bx, cs      mov ds, bx
  70.                 NEXT            END-CODE
  71.  
  72. code #linedata  ( n1 --- a1 n2 )        \ n1 = line, a1,n2 = addr & len
  73.                 pop bx                  \ get line number
  74.                 shl bx, # 1             \ convert to word offset
  75.                 mov ds, lseg            \ set DS to Linelist segment
  76.                 mov ax, 0 [bx]          \ get line address
  77.                 push ax                 \ push it
  78.                 mov dx, ax              \ save to subtract later
  79.                 mov ax, 2 [bx]          \ get next list address
  80.                 sub ax, dx              \ subtract to get line length
  81.                 mov bx, cs
  82.                 mov ds, bx              \ restore DS
  83.                 1push           end-code
  84.  
  85. code clipline ( a1 n1 --- a2 n3 )
  86.                 mov bx, ' screenchar >body      \ get the value of screenchar
  87.                 pop cx
  88.                 pop dx
  89.                 mov ax, # 40
  90.         begin
  91.                 cmp bx, # 79
  92.         > while
  93.                 sub bx, ax
  94.                 sub cx, ax
  95.                 add dx, ax
  96.         repeat
  97.                 push dx
  98.                 push cx
  99.                 next
  100.                 end-code
  101.  
  102.  
  103. code qmod       ( n1 n1 -- Remainder )          \ a quick modulus operator
  104.                 pop bx          mov dx, # 0
  105.                 pop ax
  106.                 div bx          push dx
  107.                 next
  108.                 end-code
  109.  
  110. only forth also definitions
  111.  
  112.